package com.zx.stock.controllers;

import com.zx.stock.service.PerformanceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/per/data")
public class PerformanceDataController {

    @Autowired
    private PerformanceDataService performanceDataService;

    //初始化
    @ResponseBody
    @RequestMapping(value = "/init",method = RequestMethod.GET)
    public String initData(){

        new Thread(){
            @Override
            public void run(){
                performanceDataService.initTableData();
            }
        }.start();
        return "线程执行，请耐心等待...";
    }

    //下载数据
    @ResponseBody
    @RequestMapping(value = "/load",method = RequestMethod.GET)
    public String loadData(){

        new Thread(){
            @Override
            public void run(){
                performanceDataService.loadPerformanceTableDataList();
            }
        }.start();
        return "线程执行，请耐心等待...";
    }

    //解析数据
    @ResponseBody
    @RequestMapping(value = "/analy",method = RequestMethod.GET)
    public String anylazeData(){

        new Thread(){
            @Override
            public void run(){
                performanceDataService.loadPerformance();
            }
        }.start();
        return "线程执行，请耐心等待...";
    }
}
